package facade_pattern;

import java.util.Arrays;
import java.util.List;

/**
 * @author 申书航
 * @version 1.0
 *
 * 矮人黄金矿的外观模式类，用于简化矿工的工作流程管理。
 */
public class DwarfGoldMineFacade {

    private final List<DwarfMineWorker> workers;

    public DwarfGoldMineFacade() {
        workers = Arrays.asList(
                new DwarfTunnelDigger(),
                new DwarfGoldDigger(),
                new DwarfCartOperator()
        );
    }

    /**
     * 开始新一天的工作，让所有矿工进行准备和前往矿区。
     */
    public void startNewDay() {
        workers.forEach(worker ->
                worker.action(DwarfMineWorker.Action.WAKE_UP, DwarfMineWorker.Action.GO_TO_MINE));
    }

    /**
     * 挖掘黄金，所有矿工开始工作。
     */
    public void digOutGold() {
        workers.forEach(worker -> worker.action(DwarfMineWorker.Action.WORK));
    }

    /**
     * 结束一天的工作，所有矿工返回家中并休息。
     */
    public void endDay() {
        workers.forEach(worker -> worker.action(DwarfMineWorker.Action.GO_HOME, DwarfMineWorker.Action.SLEEP));
    }
}

